//
//  MessageModule.m
//  Message
//
//  Created by Fanty on 13-12-17.
//  Copyright (c) 2013年 Fanty. All rights reserved.
//

#import "MessageModule.h"
#import "MessageViewController.h"

@implementation MessageModule

@synthesize messageManager;

-(id)init{
    self=[super init];
    
    if(self){
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccess:) name:@"CubeAuth_Success" object:nil];
        
        
    }
    
    return self;
}


- (BOOL)application:(CApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions{
    messageManager=[[MessageManager alloc] init];
    
    return YES;
}

//the ViewController represent for this Module, can be nil
-(UIViewController*)startMainViewControllerWithParams:(NSDictionary*)dict{
    return [[MessageViewController alloc] init];
}


-(void)loginSuccess:(NSNotification*)notification{
    [messageManager createNotification];
    
}


-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
    NSString* messageId=[userInfo objectForKey:@"id"];
    if([messageId length]>0)
        [messageManager syncMessageById:messageId];
}


@end
